package cz.vargagab.repo;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import cz.vargagab.domain.ClientRmiNode;
import cz.vargagab.domain.LogObject;
import cz.vargagab.domain.NumberWrapper;
import cz.vargagab.domain.RmiNode;

public class InternalServerServiceImpl implements InternalServerService{
    
	String lastChangedBy = "noone";
	Date lastChangedDate;
	Map<String,RmiNode> mapOfNodes = new HashMap<String,RmiNode>();
	NumberWrapper sharedData = new NumberWrapper(33); // zdielana premenna
	Map<ClientRmiNode,ExternalClientService> clientInterfaces = new HashMap<ClientRmiNode,ExternalClientService>();
	private List<LogObject> log = new ArrayList<LogObject>();

	@Override
	public int readData(String name) {
		return sharedData.getSharedProperty();
	}

	@Override
	public void writeData(String name, int data) {
		lastChangedBy = name;
		lastChangedDate = new Date();
		this.sharedData.setSharedProperty(data) ;
	}
	
	//Getters & Setters
	public Map<ClientRmiNode, ExternalClientService> getClientInterfaces() {
		return clientInterfaces;
	}
	public void setClientInterfaces(Map<ClientRmiNode, ExternalClientService> clientInterfaces) {
		this.clientInterfaces = clientInterfaces;
	}

	public NumberWrapper getSharedData() {
		return sharedData;
	}
	public void setSharedData(NumberWrapper sharedData) {
		this.sharedData = sharedData;
	}

	public String getLastChangedBy() {
		return lastChangedBy;
	}
	public void setLastChangedBy(String lastChangedBy) {
		this.lastChangedBy = lastChangedBy;
	}
	
	public Date getLastChangedDate() {
		return lastChangedDate;
	}
	public void setLastChangedDate(Date lastChangedDate) {
		this.lastChangedDate = lastChangedDate;
	}

	public List<LogObject> getLog() {
		return log;
	}
	public void setLog(List<LogObject> log) {
		this.log = log;
	}
	
	public Map<String,RmiNode> getMapOfNodes(){
		return mapOfNodes;
	}
	public void setMapOfNodes(Map<String, RmiNode> mapOfNodes) {
		this.mapOfNodes = mapOfNodes;
	}
	
}
